#include <algorithm>
#include <array>
#include <fmt/format.h>
#include <iostream>
#include <iterator>
#include <ostream>

char nextLetter()
{
    static char letter{ 'A' };
    return letter++;
}
int main()
{

    std::array<char, 10> chars{};
    std::ranges::fill(chars, '5');
    {
        //fill
        std::cout << "chars after filling with 5s: ";
        std::ostream_iterator<char> output{ std::cout, " " };
        std::ranges::copy(chars, output);
        std::cout << "\n";
    }
    {
        //fill_n
        std::ranges::fill_n(chars.begin(), 4, 'A');
        std::cout << "chars after filling with 'A's: ";
        std::ostream_iterator<char> output{ std::cout, " " };
        std::ranges::copy(chars, output);
        std::cout << "\n";
    }
    {
        //generate
        std::ranges::generate(chars, nextLetter);
        std::cout << "chars after filling with 'A-J's: ";
        std::ostream_iterator<char> output{ std::cout, " " };
        std::ranges::copy(chars, output);
        std::cout << "\n";
    }
    {
        //generate_n
        // std::ranges::generate_n(chars.begin(), 3,
        //                         []()
        //                         {
        //                             static char letter{ 'A' };
        //                             return letter++;
        //                         });
        std::ranges::generate_n(chars.begin(), 5, nextLetter);

        std::cout << "chars after generating K-O into elements: ";
        std::ostream_iterator<char> output{ std::cout, " " };
        std::ranges::copy(chars, output);
        std::cout << "\n";
    }
    return 0;
}